| Conditions | 5 |
| Paths | 4 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | //chosen workaround to fix behavior with HTML 5 required tag |
||
| 3 | $.fn.chosen = function (options) { |
||
| 4 | var select = $(this) |
||
| 5 | , is_creating_chosen = !!options |
||
| 6 | |||
| 7 | if (is_creating_chosen && select.css('position') === 'absolute') { |
||
| 8 | // if we are creating a chosen and the select already has the appropriate styles added |
||
| 9 | // we remove those (so that the select hasn't got a crazy width), then create the chosen |
||
| 10 | // then we re-add them later |
||
| 11 | select.removeAttr('style') |
||
| 12 | } |
||
| 13 | |||
| 14 | var ret = select.oldChosen(options) |
||
| 15 | |||
| 16 | // only act if the select has display: none, otherwise chosen is unsupported (iPhone, etc) |
||
| 17 | if (is_creating_chosen && select.css('display') === 'none') { |
||
| 18 | // https://github.com/harvesthq/chosen/issues/515#issuecomment-33214050 |
||
| 19 | // only do this if we are initializing chosen (no params, or object params) not calling a method |
||
| 20 | select.attr('style', 'display:visible; position:absolute; clip:rect(0,0,0,0)'); |
||
| 21 | select.attr('tabindex', -1); |
||
| 22 | } |
||
| 23 | return ret |
||
| 24 | }; |